package com.xiongwei.iterator;

import java.util.Iterator;
import java.util.List;

/**
 * @author XiongWei
 * @date 2024/2/20
 */
public class InfoCollegeIterator implements Iterator {

    List<Department> departmentList;
    int index = 0;

    public InfoCollegeIterator(List<Department> departmentList) {
        this.departmentList = departmentList;
    }

    @Override
    public boolean hasNext() {
        if (departmentList != null && index < departmentList.size()) {
            return true;
        }
        return false;
    }

    @Override
    public Object next() {
        if (hasNext()) {
            return departmentList.get(index++);
        }
        return null;
    }
}
